//
//  GGMainTabBarController.swift
//  SwiftWeico
//
//  Created by denjunjie1 on 15/12/15.
//  Copyright © 2015年 Gel. All rights reserved.
//

import UIKit

class GGMainTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        
        let mainTabBar = GGTabBar()
        setValue(mainTabBar, forKey: "tabBar")
        
        // Do any additional setup after loading the view.
        
        let homeVC = GGHomeViewController()
        self.addChildVC(homeVC, title: "Home", imageName: "tabbar_home")
        
        let messageVC = GGMessageViewController()
        self.addChildVC(messageVC, title: "Message", imageName: "tabbar_message_center")
        
        let discoverVC = GGDiscoverViewController()
        self.addChildVC(discoverVC, title: "Discover", imageName: "tabbar_discover")
        
        let profileVC = GGProfileViewController()
        self.addChildVC(profileVC, title: "Profile", imageName: "tabbar_profile")
        
    }

    private func addChildVC(controller : UIViewController , title : String , imageName : String){
    
        self.addChildViewController(UINavigationController(rootViewController: controller))
        
        controller.title = title
        
        controller.tabBarItem.image = UIImage(named: imageName)
        
        
        let highLightedName = imageName + "_highLighted"
        
        controller.tabBarItem.selectedImage = UIImage(named: highLightedName)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: UIControlState.Selected)
        
    
    }

}
